﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Employees_EmpLeaveList : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent(false);

            WMaster.Active = false;

            Master.DataSource = WMaster;

            wgvMaster.Visible = false;


          
            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
            master.HelpHref = "";
            master.PageName = "离职员工列表";
            master.PicUrl = "";
            master.IntiBar();
        }
    }

    private void InitializeComponent(bool action)
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Employees_EmpLeaveList));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = action;
        this.WMaster.AlwaysClose = false;
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "SEmployees.EmpLeave";
        this.WMaster.ServerModify = false;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();


    }

    protected void Search_Click(object sender, EventArgs e)
    {
        string strDep = Depart.SelectDepmanetId;
        if (strDep == "")
        {
            return;
        }
        else if (strDep == "0")
        {
            strDep = "";
        }
        else
        {
            strDep = "And Employees.DepartmentId like ('" + strDep + "%')";
        }


        string sname = SelUser.EmpName;
        if (sname != "")
        {
            sname = "And Employees.EmpName like ('%" + sname + "%')";
        }
        else
        {
            sname = "";
        }



        InitializeComponent(true);

        WMaster.SetWhere("1=1 " + strDep + sname);

        WMaster.Active = true;

        Master.DataSource = WMaster;

        wgvMaster.Visible = true;

        Master.Reload();
    }

    protected void wgvMaster_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView drv = (DataRowView)e.Row.DataItem;




            ImageButton imb = (ImageButton)e.Row.FindControl("imb");


            imb.Attributes.Add("onclick", "location.href='EmpLeave.aspx?action=edit&lid=" + drv["EmpLeaveId"].ToString() + "&eid=" + drv["EmployeeId"].ToString() + "&ename=" + Server.UrlEncode(drv["EmpName"].ToString()) + "';return false");
            //ImageButton ibt = (ImageButton)e.Row.FindControl("ibdetail");
        }
    }
   
}
